#include "PanelScore.h"
#include "Config.h"


// define zorder label score
#define kZorderLabelScore 2

// define tag label score
#define kTagLabelScore 100

using namespace cocos2d;

PanelScore::PanelScore()
{
}
PanelScore::~PanelScore()
{
}

void PanelScore::fCreateLabelScore(CCLayer* parent, CCPoint pos, int score)
{
	mLabelScore = fCreateLabelScore(pos, score);

	if(mLabelScore == NULL){
		return;
	}

	parent->addChild(mLabelScore, kZorderLabelScore, kTagLabelScore);
}

CCLabelTTF* PanelScore::fCreateLabelScore(CCPoint pos, int score)
{
	CCString* string = CCString::createWithFormat("%d", score);

	mLabelScore = CCLabelTTF::create(string->getCString(), kFontName, kFontSize);

	mLabelScore->setPosition(ccp(pos.x, pos.y));

	if(mLabelScore == NULL)
	{
		return NULL;
	}

	return mLabelScore;
}

void PanelScore::fUpdateLabelScore(int score)
{
	if(mLabelScore == NULL)
	{
		CCLog("error ! Label score is null");
		return;
	}

	CCString* strp = CCString::createWithFormat("%d", score);

	mLabelScore->setString(strp->getCString());
}

void PanelScore::fUpdateLabelScore(CCLabelTTF* lbScore, int score)
{
	if(lbScore == NULL)
	{
		CCLog("error ! Label score is null");
		return;
	}

	CCString* strp = CCString::createWithFormat("%d", score);

	lbScore->setString(strp->getCString());
}